package cat200;


import java.sql.*;
import javax.swing.JOptionPane;
import java.awt.Component;

/**
 *
 * @author huitian
 */
public class specialOrder extends javax.swing.JFrame {

	public static int id_passing;
	private String url = "jdbc:derby://localhost:1527/sample";
    private String userID = "app";
    private String userPW = "app";
    private Connection conn;
    private Statement stmt;
    private ResultSet rset;
    
    int invoice = 0;
    int special = 0;
    int getRow = 0;
    private Component frame;
      
    
    public specialOrder() {
    	super("Special Order");
        initComponents();
        setLocationRelativeTo(null);
        
        String query1 = "SELECT INV_NUM FROM INVOICE WHERE INV_NUM >= ALL (SELECT INV_NUM FROM INVOICE)";
        try{
        	rset = getResultSet(query1);
        	
        	while (rset.next())
        	{invoice = rset.getInt(1);
        	invoice = invoice + 1;
        	}
        	
        }
        catch
        (Exception e){} 
    }
    
    public specialOrder(int id, int code) {
    	initComponents();
        setLocationRelativeTo(null);
        id_passing = id;
    	specialTable();
    	invoice=code;
    }
    
    private void createConnection()
    {
        try
        {
        	Class.forName("org.apache.derby.jdbc.ClientDriver");
            conn=DriverManager.getConnection(url, userID, userPW);
        }
        catch (Exception except)
        {
            except.printStackTrace();
        }
    }
    
    private ResultSet getResultSet (String query)
    {
    	createConnection();
    	ResultSet outcome = null;
    	try
    	{
    		stmt = conn.createStatement();
    		outcome = stmt.executeQuery(query);
    	}
    	catch (SQLException ex)
    	{
    		ex.printStackTrace();
    	}
    	return outcome;
    }
    
    public void specialTable()
    {
    	int row = 0;
    	String sql = "SELECT * FROM SPECIAL WHERE INV_NUM = "+invoice;
    	
    	ResultSet rset;
        createConnection();
        
        try{
        	rset = getResultSet(sql);
        	
        	while (rset.next())
        	{ 
        		jTable1.setValueAt(rset.getString(2), row, 0);
        		jTable1.setValueAt(rset.getString(3), row, 1);
        		jTable1.setValueAt(rset.getString(4), row, 2);
        		jTable1.setValueAt(rset.getString(5), row, 3);
        		jTable1.setValueAt(rset.getString(6), row, 5);
        		jTable1.setValueAt(rset.getString(7), row, 4);
        		jTable1.setValueAt(rset.getString(8), row, 6);
        		row++;
        	}
        }
        catch
        (Exception e){
        	System.out.println(e);
        }
    	
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
     private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jComboBox12 = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        jComboBox11 = new javax.swing.JComboBox();
        jLabel16 = new javax.swing.JLabel();
        jComboBox10 = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();
        jComboBox8 = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jComboBox7 = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jButton12 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jSeparator6 = new javax.swing.JSeparator();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        jSeparator5 = new javax.swing.JSeparator();
        jButton13 = new javax.swing.JButton();
        jButton14 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Times New Roman", 3, 24));
        jLabel1.setForeground(new java.awt.Color(241, 24, 201));
        jLabel1.setText("JANICE'S SPECIAL ORDER ");

        jLabel11.setText("TYPE OF CAKE:");

        jComboBox12.setModel(new javax.swing.DefaultComboBoxModel(new String[] {"FRUIT CAKE", "CHEESE CAKE", "CHOCOLATE CAKE", "ICE CREAM CAKE" }));

        jLabel10.setText("FLAVOUR       :");

        jComboBox11.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "MOCHA", "ALMOND", "PANDAN", "BUTTER", "DARK CHOCOLATE" }));
        jComboBox11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox11ActionPerformed(evt);
            }
        });

        jLabel16.setText("OCCASION     :");

        jComboBox10.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "BIRTHDAY", "WEDDING", "CELEBRATION", "CORPORATE EVENT" }));
        jComboBox10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox10ActionPerformed(evt);
            }
        });

        jLabel13.setText("LAYER             :");

        jComboBox8.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5" }));
        jComboBox8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox8ActionPerformed(evt);
            }
        });

        jLabel12.setText("WEIGHT(KG)  :");

        jLabel14.setText("SHAPE            :");

        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        jComboBox7.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "LOVE", "ROUND", "TRIANGLE", "RECTANGLE" }));
        jComboBox7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox7ActionPerformed(evt);
            }
        });

        jLabel2.setBorder(javax.swing.BorderFactory.createTitledBorder("SPECIAL ORDER"));

        jButton12.setText("BACK");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        jButton11.setText("CONFIRM");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null}
            },
            new String [] {
                "TYPE", "FLAVOUR", "OCCASION", "LAYER", "WEIGHT", "SHAPE", "PRICE"
            }
        ));
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jTable1MousePressed(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);

        jLabel3.setBorder(javax.swing.BorderFactory.createTitledBorder("ORDER LIST"));

        jButton13.setText("ENTER");
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });

        jButton14.setText("DELETE");
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });

        jButton10.setText("CLEAR");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 680, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(20, 20, 20)
                            .addComponent(jLabel1))
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(10, 10, 10)
                                    .addComponent(jLabel11)
                                    .addGap(7, 7, 7)
                                    .addComponent(jComboBox12, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(10, 10, 10)
                                    .addComponent(jLabel10)
                                    .addGap(8, 8, 8)
                                    .addComponent(jComboBox11, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(10, 10, 10)
                                    .addComponent(jLabel16)
                                    .addGap(7, 7, 7)
                                    .addComponent(jComboBox10, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(10, 10, 10)
                                    .addComponent(jLabel13)
                                    .addGap(5, 5, 5)
                                    .addComponent(jComboBox8, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(10, 10, 10)
                                    .addComponent(jLabel12)
                                    .addGap(11, 11, 11)
                                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(10, 10, 10)
                                    .addComponent(jLabel14)
                                    .addGap(4, 4, 4)
                                    .addComponent(jComboBox7, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(20, 20, 20)
                                    .addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(20, 20, 20)
                                    .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(10, 10, 10)
                                    .addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(10, 10, 10)
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(10, 10, 10)
                                    .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(40, 40, 40)
                                    .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(140, 140, 140)
                                    .addComponent(jButton13, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(160, 160, 160)
                                    .addComponent(jButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 420, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGap(0, 0, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 450, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(jLabel1)
                    .addGap(42, 42, 42)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(30, 30, 30)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel11)
                                .addComponent(jComboBox12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(15, 15, 15)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel10)
                                .addComponent(jComboBox11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(15, 15, 15)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel16)
                                .addComponent(jComboBox10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(15, 15, 15)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel13)
                                .addComponent(jComboBox8, javax.swing.GroupLayout. PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(15, 15, 15)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel12)
                                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(15, 15, 15)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel14)
                                .addComponent(jComboBox7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(65, 65, 65)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jButton12)
                                .addComponent(jButton11)))
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 380, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(290, 290, 290)
                            .addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(60, 60, 60)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(40, 40, 40)
                            .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(20, 20, 20)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jButton13)
                                .addComponent(jButton10)))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(320, 320, 320)
                            .addComponent(jButton14))
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 380, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(0, 0, Short.MAX_VALUE)))
        );

        pack();
    }// </editor-fold>



    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
    	try {
                
        	String query = "DELETE FROM SPECIAL WHERE INV_NUM = " +invoice ;
        	
        	  
        	  stmt.execute(query);
                }

        
        
        catch
        (Exception e){
        	System.out.println(e);
        }
    	

        this.setVisible(false);
        new Main(specialOrder.id_passing).setVisible(true);
    }                                         

    private void jComboBox11ActionPerformed(java.awt.event.ActionEvent evt) {                                            
        // TODO add your handling code here:
    	
    }                                           

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
    	
    	this.setVisible(false);
        new customerDetails().setVisible(true);
    }                                     

    private void jComboBox10ActionPerformed(java.awt.event.ActionEvent evt) {                                            
        // TODO add your handling code here:
    }                                           

    private void jComboBox8ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
    }                                          

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {                                            
        // TODO add your handling code here:
    }                                           

    private void jComboBox7ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
    }                                          

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:

    	String WEIGHT = jTextField1.getText();
    	
    	if (WEIGHT.equals(""))
    	{
    		JOptionPane.showMessageDialog(null, "ERROR! WEIGHT CAN'T BE NULL!");
    	}
    	

        else
        {
    	String TYPE = (String)jComboBox12.getSelectedItem();
        String FLAVOR = (String)jComboBox11.getSelectedItem();
        String OCCASION = (String)jComboBox10.getSelectedItem();
        String LAYER = (String)jComboBox8.getSelectedItem();
        String SHAPE = (String)jComboBox7.getSelectedItem();
        double temp = Double.parseDouble(WEIGHT);
        double PRICE = 0.00;
        
        
        if (TYPE == "FRUIT CAKE")
        	PRICE = 26.90 * temp * 1.1;
        else if (TYPE == "CHEESE CAKE")
        	PRICE = 34.90 * temp * 1.1;
        else if (TYPE == "CHOCOLATE CAKE")
        	PRICE = 29.90 * temp * 1.1;
        else if (TYPE == "ICE CREAM CAKE")
        	PRICE = 39.90 * temp * 1.1;

        		
        String sql = "SELECT SPECIAL_CODE FROM SPECIAL WHERE SPECIAL_CODE >= ALL (SELECT SPECIAL_CODE FROM SPECIAL)";
    	
    	ResultSet rset;
        createConnection();
        
        try{
        	rset = getResultSet(sql);
        	
        	while (rset.next())
        	{special = rset.getInt(1);
        	special = special + 1;
        	}
        	
        }
        catch
        (Exception e){}
        
        
        try
        {
        
        String query = "INSERT INTO SPECIAL VALUES (" + special + ",'" + TYPE 
    	+ "','" + FLAVOR + "','" + OCCASION + "','" + LAYER + "','" + SHAPE
          + "'," + WEIGHT + "," + PRICE +" , " + invoice + " ) ";
    	
        stmt.execute(query);
        
    	special++;
    	}
        
        catch
        (Exception e){}
        
        specialTable();
        }

    }                                    

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
    	int store = 0;
    	
    	 if ((jTable1.getSelectedRow() == -1)||(jTable1.getValueAt(jTable1.getSelectedRow(),0) == null))
             JOptionPane.showMessageDialog(null, "PLEASE SELECT A ROW!", "ERROR!", JOptionPane.WARNING_MESSAGE);
         
    	 
    	else
    	{
    		if (jButton14.getText().equals("DELETE"))  
            {
        		Object[] options = {"YES","NO"};
                int Selection = JOptionPane.showOptionDialog(frame,"CONFIRM DELETE?","Alert!",
                        JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE,null,options,options[0]);
            
            if (Selection == 0) //confirm clear
            {
            	String query = "SELECT SPECIAL_CODE FROM SPECIAL WHERE INV_NUM ="+invoice;
    	
            	ResultSet rset;
            	createConnection();
            	int i=0;
            	try{
            		rset = getResultSet(query);
        	
            		while (rset.next())
            		{	
            			if(i==getRow)
            				break;	
            			store = rset.getInt(1);
            			System.out.println("io= "+store);
        			
            			++i;
            		}
            		System.out.println(store);
            	}
            	catch
            	(Exception e){}
        
            	try{
            		String sql = "DELETE FROM SPECIAL WHERE SPECIAL_CODE = " + store;
            		stmt.execute(sql);
        	
            		int row1= jTable1.getRowCount();
            		System.out.println(row1);
            		for (int j = 0; j < row1 ; j++)
            		{
            			jTable1.setValueAt(null, j, 0);
            			jTable1.setValueAt(null, j, 1);
            			jTable1.setValueAt(null, j, 2);
            			jTable1.setValueAt(null, j, 3);
            			jTable1.setValueAt(null, j, 4);
            			jTable1.setValueAt(null, j, 5);
            			jTable1.setValueAt(null, j, 6);
            	
            		}
            		specialTable();
            	}
        
            	catch(Exception e){}
            }
            else if (Selection == 1) //don't delete
            { } 
            else System.out.println("Error in deleting");
            } //end if
    	}
    }                                         

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
    	if (jButton10.getText().equals("CLEAR"))  
        {
    		Object[] options = {"YES","NO"};
            int Selection = JOptionPane.showOptionDialog(frame,"CONFIRM CLEAR?","Alert!",
                    JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE,null,options,options[0]);
        
        if (Selection == 0) //confirm clear
        {
    	
    	try {
            
        	String query = "DELETE FROM SPECIAL WHERE INV_NUM =" +invoice ;
        	
        	  
        	  stmt.execute(query);
                }

        
        catch
        (Exception e){
        	System.out.println(e);
        }
        
        jTable1.removeAll();
        
        int row1= jTable1.getRowCount();
        System.out.println(row1);
        for (int i = 0; i < row1 ; i++)
        {
        	jTable1.setValueAt(null, i, 0);
        	jTable1.setValueAt(null, i, 1);
        	jTable1.setValueAt(null, i, 2);
        	jTable1.setValueAt(null, i, 3);
        	jTable1.setValueAt(null, i, 4);
        	jTable1.setValueAt(null, i, 5);
        	jTable1.setValueAt(null, i, 6);
        	
        }
        
        specialTable();
        
        }  //end if confirm delete
            else if (Selection == 1) //don't delete
            { } 
            else System.out.println("Error in deleting");
        } //end if

    }                                         

    private void jComboBox12ActionPerformed(java.awt.event.ActionEvent evt) {                                            
        // TODO add your handling code here:
    } 
    

    private void jTable1MousePressed(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
    	getRow = jTable1.getSelectedRow()+1;
    	System.out.println(getRow);
    }
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new specialOrder().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JComboBox jComboBox10;
    private javax.swing.JComboBox jComboBox11;
    private javax.swing.JComboBox jComboBox12;
    private javax.swing.JComboBox jComboBox7;
    private javax.swing.JComboBox jComboBox8;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator5;
    private javax.swing.JSeparator jSeparator6;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration

}
